"""元组类型配置

包含tuple类型的C++映射和方法配置
"""

# 元组类型配置
CONFIG = {
    # 基础 tuple 类型（无类型参数）
    "tuple": {
        "cpp_type": "mc::variants",  # 无类型参数的 tuple 映射为 variants
        "includes": ["mc/variant.h"],
        "default_value": "mc::variants{}",
        "is_type": True,
        "module": "builtins",
        "methods": {
            "__getitem__": {
                # 弱类型 tuple (mc::variants) 统一使用 ResultT 模板参数
                # 返回类型是 Any，对应 mc::variant
                "signatures": ["__getitem__(self, index: int) -> Any"],
                "templates": ["mcpy::tuple_getitem<mc::variant>({self}, {index})"],
                "includes": ["mcpy/builtins/tuple.h"],
                "priority": 1,
            },
            "count": {
                "signatures": ["count(self, item: Any) -> int"],
                "templates": ["mcpy::tuple_count({self}, {item})"],
                "includes": ["mcpy/builtins/tuple.h"],
                "priority": 1,
            },
            "index": {
                "signatures": ["index(self, item: Any) -> int"],
                "templates": ["mcpy::tuple_index({self}, {item})"],
                "includes": ["mcpy/builtins/tuple.h"],
                "priority": 1,
            },
            "__len__": {
                "signatures": ["__len__(self) -> int"],
                "templates": ["{self}.size()"],
                "includes": [],
                "priority": 1,
            },
        },
    },
    # 泛型 tuple 类型（支持可变参数）
    "tuple[T, Args...]": {
        "cpp_type": "std::tuple<T, Args...>",
        "includes": ["<tuple>"],
        "default_value": "std::tuple<T, Args...>()",
        "satisfies_protocols": [
            "Sequence",
            "Iterable",
            "Sized",
            "Container",
            "Reversible",
            "Hashable",
        ],  # 满足的 Protocol
        "methods": {
            "__getitem__": [
                {
                    # 常量索引：编译时模板版本
                    # 常量版本配置更高优先级，不过即使优先级一样，常量参数的精确匹配也能获取更高的分数
                    # 统一使用 ResultT 模板参数，Args... 由编译器推导
                    "signatures": ["__getitem__(self, index: Literal[int]) -> T"],
                    "templates": ["mcpy::tuple_getitem<{index}, {T}>({self})"],
                    "includes": ["mcpy/builtins/tuple.h"],
                    "priority": 10,
                },
                {
                    # 非常量索引：运行时版本
                    # 统一使用 ResultT 模板参数
                    "signatures": ["__getitem__(self, index: int) -> T"],
                    "templates": ["mcpy::tuple_getitem<{T}>({self}, {index})"],
                    "includes": ["mcpy/builtins/tuple.h"],
                    "priority": 1,
                },
            ],
            "count": {
                "signatures": ["count(self, item: Any) -> int"],
                "templates": ["mcpy::tuple_count({self}, {item})"],
                "includes": ["mcpy/builtins/tuple.h"],
                "priority": 1,
            },
            "index": {
                "signatures": ["index(self, item: Any) -> int"],
                "templates": ["mcpy::tuple_index({self}, {item})"],
                "includes": ["mcpy/builtins/tuple.h"],
                "priority": 1,
            },
            "__len__": {
                "signatures": ["__len__(self) -> int"],
                "templates": ["mcpy::tuple_len({self})"],
                "includes": [],
                "priority": 1,
            },
        },
    },
    # Python 3.9+ 兼容性：大写类型映射
    "Tuple": {
        "is_type": True,
        "type_alias": "tuple",
        "module": "typing",
    },
}
